{layout name="public/layout" /}
<!-- 内容主体区域 -->
<div class="site-block">
    <fieldset class="layui-elem-field">
        <legend>配置参数</legend>
        <div class="layui-field-box">
            <form class="layui-form layui-form-pane" method="post">
                <input type="hidden" name="id" value="{:GetConfDate('id')}"/>
                {volist name="set_data" id="vos"}

                {if condition="$vos.c_type eq 7"}
                <div class="layui-form-item">
                    <label class="layui-form-label">{$vos.cname}</label>
                    <div class="layui-input-block">
                        <?php $array = explode('|',$vos['c_values']);?>
                        <?php foreach($array as $k=>$y){?>
                        <input type="radio" name="{$vos.ename}" value="{$y}" title="{$y}" {if condition="$y eq GetConfDate($vos['ename'])"} checked{/if}>
                        <?php }?>
                    </div>
                </div>
                {/if}
                {if condition="$vos.c_type eq 6"}
                <div class="layui-form-item">
                    <label class="layui-form-label">{$vos.cname}</label>
                    <div class="layui-input-inline layui-upload">
                        <button type="button" class="layui-btn yh_fl" id="{$vos.ename}"><i class="layui-icon"></i>上传图片</button>
                        <img class="layui-upload-img" id="demo1_{$vos.ename}" src='{:GetConfDate($vos["ename"])}' style="width: 100%;height: 36px">
                    </div>
                    <input class="layui-input layui-btn-disabled" name="{$vos.ename}" id="img_{$vos.ename}" style="line-height: 36px;width: 50%;" type="hidden" value='{:GetConfDate($vos["ename"])}' />

                </div>
                <script>
                    layui.use('upload', function(){
                        var $ = layui.jquery
                                ,upload = layui.upload;
                        var id      = {$vos.ename};
                        //普通图片上传
                        var uploadInst = upload.render({
                                    elem: id //绑定元素
                                    ,accept:'file'
                                    ,url: '{:url("Common/uploadTicketFile")}' //上传接口
                                ,done: function(res){
                            if(res.code==1){
                                layer.msg(res.msg,{time:500},function(){


                                    $('#img_{$vos.ename}').val(res.imgUrl);
                                    $('#demo1_{$vos.ename}').attr('src',res.imgUrl);
//                                    $(".{$vos.ename}").val(res.imgUrl);

                                })
                            }else{
                                layer.msg(res.msg,function(){})
                            }
                        }
                        ,error: function(){
                            //请求异常回调
                        }
                    });

                    });
                </script>
                {/if}
                {if condition="$vos.c_type eq 1"}
                <div class="layui-form-item">
                    <label class="layui-form-label">{$vos.cname}</label>
                    <div class="layui-input-block">
                        <input type="text" name="{$vos.ename}" required="" lay-verify="required" placeholder="请输入{$vos.cname}" autocomplete="off" class="layui-input" value='{:GetConfDate($vos["ename"])}'>
                    </div>
                </div>
                {/if}
                {if condition="$vos.c_type eq 5"}

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">{$vos.cname}</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入{$vos.cname}" name="{$vos.ename}" class="layui-textarea">{:GetConfDate($vos["ename"])}</textarea>
                    </div>
                </div>

                {/if}
                {/volist}

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>

                    </div>
                </div>
            </form>
        </div>
    </fieldset>
</div>
<script>

    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            $.ajax({
                        url: "{:url('Config/ConfigList')}",
                        type: "post",
                        data: data.field,
                        dataType: "json"
                    }).done(function(res) {
                        if(res.code==0){
                            layer.msg(res.msg,function(){});
                        }else{
                            layer.msg(res.msg,function(){
                                window.location.href=res.url;
                            });
                        }
                    })
                    .fail(function() {
                        //实现抖一抖效果
                        layer.msg('系统异常，请稍后再试',function(){})
                    });



            return false;

        });



    });

</script>